import { request } from 'umi';

export async function getTableList(params: object = {}) {
  return request<ApiResponse.FilterResponse<Generator.TableInfo>>('/api/Generator/GetTableList', {
    method: 'GET',
    params: params,
  });
}

export async function validateFileExist(params: object = {}) {
  return request<boolean>('/api/Generator/ValidateFileExist', {
    method: 'GET',
    params: params,
  });
}

export async function generateFrontEntity(data: Generator.GenerateRequest) {
  return request<ApiResponse.ResultModel<string>>('/api/Generator/GenerateFrontEntity', {
    method: 'POST',
    data: data,
  });
}

export async function commonGenerate(data: Generator.GenerateRequest) {
  return request<ApiResponse.ResultModel<string>>('/api/Generator/CommonGenerate', {
    method: 'POST',
    data: data,
  });
}

export async function generateTableIndex(data: Generator.GenerateRequest) {
  return request<ApiResponse.ResultModel<string>>('/api/Generator/GenerateTableIndex', {
    method: 'POST',
    data: data,
  });
}

export async function generateForm(schema: any) {
  return request<ApiResponse.ResultModel<string>>('/api/Generator/GenerateForm', {
    method: 'POST',
    data: { schema: JSON.stringify(schema) },
  });
}

export async function getTableInfo(tableName: string) {
  return request<ApiResponse.ResultModel<Generator.TableInfo>>('/api/Generator/GetTableInfo', {
    method: 'Get',
    params: { tableName: tableName },
  });
}

export async function generateScreenShot(id: number) {
  return request<ApiResponse.ResultModel<string>>('/api/Generator/GenerateScreenImg', {
    method: 'Get',
    params: { id: id },
  });
}
